/**
 * Created by ming on 2016/1/22.
 */
class IfQuit extends eui.Component {
    public constructor() {
        super();
        this.skinName = IfQuitSkin;
        if (IfQuit.ins) {
            throw new Error("请使用单例调用  IfQuit");
        }
    }

    protected createChildren() {
        super.createChildren();
        /**退出 */
        this.ok.addEventListener(egret.TouchEvent.TOUCH_TAP, this.tuichuFunc, this);
        /**继续 */
        this.cancel.addEventListener(egret.TouchEvent.TOUCH_TAP, this.jixuFunc, this);
    }

    /**是否退出面板 */
    public static getins() {
        if (this.ins == undefined) {
            this.ins = new IfQuit();
        }
        return this.ins;
    }
    private static ins: IfQuit;
    /**退出 */
    private ok: eui.Image;
    /**继续 */
    private cancel: eui.Image;

    /**返回主界面 */
    private tuichuFunc() {
        var tw = Tween.get(this.ok);
        tw.to({ scaleX: 1.2, scaleY: 1.2 }, 200);
        tw.to({ scaleX: 1, scaleY: 1 }, 200);
        tw.call(() => {
            if (IfQuit.ins.parent) {
                IfQuit.ins.parent.removeChild(this);
            }

        })
        // TableUI.Instance().quitFunc();
    }
    /**继续游戏 */
    private jixuFunc() {
        var tw = Tween.get(this.cancel);
        tw.to({ scaleX: 1.2, scaleY: 1.2 }, 200);
        tw.to({ scaleX: 1, scaleY: 1 }, 200);
        tw.call(() => {
            if (IfQuit.ins.parent) {
                IfQuit.ins.parent.removeChild(this);
            }

        })
    }

}